#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
    long long count = 0;
    pid_t child;
    int wait_ret;
    long  orig_eax;
    
    child = fork();

    if (child == 0) {
        ptrace(PTRACE_TRACEME, 0, NULL, NULL);
        execl("/bin/ls", "ls", NULL);
    }
    else {
        wait(&wait_ret);
        while (wait_ret == 1407) {
            count++;
    
            if (ptrace(PTRACE_SINGLESTEP, child, 0, NULL) != 0)
                exit(EXIT_FAILURE);

            wait(&wait_ret);
        }
    }
    printf("instructions = %lld\n", count);
    return 0;
}
